<template>
  <div class="cardContainer" style="width: 100%">
    <div class="card h-62" style="width: 100%">
      <p class="city">{{ qweather.real.station.city }}</p>
      <p class="weather">{{ qweather.info }},{{ qweather.sunrise }}-{{ qweather.sunset }}</p>
      <img :src="emitEvent(qweather.info)" style="width: 70px; height: 70px" mode="" />
      <p class="temp">{{ qweather.temperature }}°</p>

      <div class="minmaxContainer">
        <div class="min">
          <p class="minHeading">最低温度</p>
          <p class="minTemp text-blue-500">{{ qweather.today.min_temp }}°</p>
        </div>
        <div class="max">
          <p class="maxHeading">最高温度</p>
          <p class="maxTemp text-red-500">{{ qweather.today.max_temp }}°</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { toRefs } from 'vue';

// Define props
const props = defineProps({
  qweather: Object, // Define qweather as an object prop

  onGeticon: Function,
});

// Destructure the qweather prop
const { qweather } = toRefs(props);
function emitEvent(data) {
  if (props.onGeticon) {
    return props.onGeticon(data); // Call the onGeticon callback function
  } // Emit the event with the argument to call the parent method
}
</script>
<style scoped lang="less">
.cardContainer {
  width: fit-content;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  position: relative;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 10px;
  border-radius: 10px;
  backdrop-filter: blur(30px);
  background-color: rgba(65, 65, 65, 0.308);
  border: 1px solid rgba(255, 255, 255, 0.089);
  cursor: pointer;
}

.city {
  font-weight: 700;
  font-size: 0.9em;
  letter-spacing: 1.2px;
  color: white;
}

.weather {
  font-weight: 500;
  font-size: 0.7em;
  letter-spacing: 1.2px;
  color: rgb(197, 197, 197);
}

.temp {
  font-size: 2em;
  color: white;
  font-weight: 700;
}

.minmaxContainer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.min,
.max {
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0px 20px;
  gap: 4px;
}

.max {
  align-items: flex-start;
  border-left: 2px solid white;
}

.maxHeading,
.minHeading {
  font-size: 0.7em;
  font-weight: 600;
  color: white;
}

.maxTemp,
.minTemp {
  font-size: 1em;
  font-weight: 800;
}

.cardContainer::before {
  width: 100px;
  height: 100px;
  content: '';
  position: absolute;
  background-color: rgb(144, 161, 255);
  z-index: -1;
  border-radius: 50%;
  left: 100px;
  top: 50px;
  transition: all 1s;
}

.cardContainer:hover::before {
  transform: translate(-50px, 50px);
}
</style>
